import React, { Component } from 'react';
import { Form, Input,message } from 'antd';

const Item = Form.Item;

export default class AddUser extends Component {
    state = {
        username: '',
        password: ''
    }
    render() {
        const formLayout = {
            labelCol: { span: 5 },
            wrapperCol: { span: 18 }
        }
        // getDetail = ()=> this.state;
        // var username = document.getElementById('username').value;
        // var password = document.getElementById('password').value;
        // console.log(password,username)
        // const {handleOk} = this.props;
        // console.log(handleOk);
        // handleOk(this.Form);
        // console.log(this.form);
        // const { onFinish } = this.props
        // const values = this.state;
        // onFinish(values)
        // const  onFinish = (values) => {
        //     fetch('http://82.157.94.115:2005/zhregister', {
        //         method: 'POST',
        //         body: JSON.stringify(values),
        //         headers: {
        //             'Content-Type': 'application/json'
        //         }
        //     })
        //         .then(res => res.json())
        //         .then(res => {
        //             this.getUsers();
        //             message.success('用户添加成功！');
        //         })
        // }
        return (
            <div>
                <Form {...formLayout} >
                    <Item
                        label="用户名"
                        name='username'
                        rules={[
                            {
                                required: true,
                                message: '请输入用户名',
                            },
                        ]}
                    >
                        <Input type='text' placeholder='请输入用户名' id='username' onChange={(e)=>this.setState({username:e.target.value})}></Input>
                    </Item>
                    <Item
                        label="密码"
                        name='password'
                        rules={[
                            {
                                required: true,
                                message: '请输入密码',
                            },
                        ]}
                    >
                        <Input type='password' placeholder='请输入密码' id='password' onChange={(e)=>this.setState({password:e.target.value})}></Input>
                    </Item>
                </Form>
            </div>
        )
    }
}

//onChange={(e)=>this.setState({username:e.target.value})}
//onChange={(e)=>this.setState({password:e.target.value})}
